package panda.rmi.client.impl;

import java.rmi.Naming;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import panda.rmi.client.DriverAdapter;
import panda.rmi.server.ServerConnection;
import panda.rmi.server.ServerDriver;

public class PandaDriver extends DriverAdapter {
	public Connection connect(String url, Properties prop) throws SQLException {
		try {
			ServerDriver drv = (ServerDriver) Naming.lookup(url.replace("jdbc:panda", "rmi") + "/panda");
			
			ServerConnection conn = drv.connect();
			
			return new PandaConnection(conn);
		}
		catch (Exception e) {
			throw new SQLException(e);
		}
	}
}
